package test06;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {
        //定义serversocket对象
        ServerSocket serverSocket = new ServerSocket(10000);
        //获取链接
        Socket socket = serverSocket.accept();
        //提取链接中输入流对象
        InputStream inputStream = socket.getInputStream();
        InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
        BufferedReader reader = new BufferedReader(inputStreamReader);
        //读取数据
        int b;
        while ((b = reader.read()) != -1) {
            System.out.print((char) b);
        }
        //释放链接
        socket.close();
        serverSocket.close();
    }
}
